<template>
	<view class="inspection-list">

		<scroll-view class="list-container" scroll-y="true">
			<!-- 使用 v-for 遍历巡检项列表 -->
			<navigator v-for="(item, index) in inspectionItems" :key="index" class="item" :url="item.url">
				<!-- 第一行：标题和单号 -->
				<view class="item-title">
					<text class="title" :style="{ backgroundColor: getTitleBackgroundColor(item.flag) }">
						{{ item.title }}
					</text>
					<text class="number">
						{{ item.number }}
					</text>
				</view>
				<!-- 第二行：巡检时间 - 其他项 -->
				<view class="item-time">
					<text>{{ item.inspectionTime }}</text>
					<text>{{ item.remark }}</text>
				</view>
			</navigator>
			
			<u-divider v-if="this.loading">已经到底了</u-divider>
		</scroll-view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				loading:true,
				inspectionItems: [{
						title: '事件工单',
						number: 'SJGD-996158043638988801',
						inspectionTime: '2024-07-22  流量计-故障',
						flag: 1
					},
					{
						title: '日常巡检',
						number: 'RCXJ-100421676784680960',
						inspectionTime: '2024-07-22-白班',
						flag: 2
					},
					{
						title: '设备巡检',
						number: 'SBXJ-937718593620017153',
						inspectionTime: '2024-06-24 16:00',
						flag: 3
					},
					{
						title: '保养工单',
						number: 'BYGD-100820302988050432',
						inspectionTime: '2024-07-22',
						flag: 4
					},
					{
						title: '事件工单',
						number: 'SJGD-996158043638988801',
						inspectionTime: '流量计-故障',
						flag: 1
					},
					{
						title: '日常巡检',
						number: 'RCXJ-100421676784680960',
						inspectionTime: '2024-07-22-白班',
						flag: 2
					},
					{
						title: '设备巡检',
						number: 'SBXJ-937718593620017153',
						inspectionTime: '2024-06-24 16:00',
						flag: 3
					},
					{
						title: '保养工单',
						number: 'BYGD-100820302988050432',
						inspectionTime: '2024-07-22',
						flag: 4
					},
					{
						title: '事件工单',
						number: 'SJGD-996158043638988801',
						inspectionTime: '流量计-故障',
						flag: 1
					},
					{
						title: '日常巡检',
						number: 'RCXJ-100421676784680960',
						inspectionTime: '2024-07-22-白班',
						flag: 2
					},
					{
						title: '设备巡检',
						number: 'SBXJ-937718593620017153',
						inspectionTime: '2024-06-24 16:00',
						flag: 3
					},
					{
						title: '保养工单',
						number: 'BYGD-100820302988050432',
						inspectionTime: '2024-07-22',
						flag: 4
					},

				]
			};
		},
		mounted() {
			this.getOrderAllMseeage()
		},
		methods: {
			getTitleBackgroundColor(flag) {
				switch (flag) {
					case '1':
						return '#99ff99';
					case '2':
						return '#ffff99';
					case '3':
						return '#9999ff';
					case '4':
						return '#ff9999';
					default:
						return '#f0f0f0';
				}
			},
			getOrderAllMseeage() {
				this.$u.api.getOrderAllMseeage({
					"algorithmProcessId": "getOrderAllMseeage",
					"param": {
						"data": {
							structure_uuid: uni.getStorageSync('navId')
						}
					}
				}).then(res => {
					this.inspectionItems = res.data.data.result
				})
			}
		}
	};
</script>

<style lang="scss">
	@import 'style/message.css';
</style>